package com.softwareinlife.gae.sample.datastore.model;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class DeviceModel {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;

	@Persistent
	private String type;

	@Persistent
	private String number;

	@Persistent
	private UserModel user;

	@Persistent
	private Date createdDate;

	/**
	 * Constructor
	 */
	public DeviceModel() {
		super();
	}

	/**
	 * Constructor
	 * 
	 * @param type
	 * @param number
	 */
	public DeviceModel(String type, String number) {
		super();
		this.type = type;
		this.number = number;
		this.createdDate = new Date();
	}

	/**
	 * Constructor
	 * 
	 * @param key
	 * @param type
	 * @param number
	 * @param user
	 * @param createdDate
	 */
	public DeviceModel(Key id, String type, String number, UserModel user,
			Date createdDate) {
		super();
		this.id = id;
		this.type = type;
		this.number = number;
		this.user = user;
		this.createdDate = createdDate;
	}

	/**
	 * @return the id
	 */
	public Key getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Key id) {
		this.id = id;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the number
	 */
	public String getNumber() {
		return number;
	}

	/**
	 * @param number
	 *            the number to set
	 */
	public void setNumber(String number) {
		this.number = number;
	}

	/**
	 * @return the user
	 */
	public UserModel getUser() {
		return user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(UserModel user) {
		this.user = user;
	}

	/**
	 * @return the createdDate
	 */
	public Date getCreatedDate() {
		return createdDate;
	}

	/**
	 * @param createdDate
	 *            the createdDate to set
	 */
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "DeviceModel [id=" + id + ", type=" + type + ", number="
				+ number + ", createdDate=" + createdDate + "]";
	}

}
